//
//  MainTabBarController.swift
//  MyWeibo
//
//  Created by apple on 15/9/30.
//  Copyright © 2015年 LBL. All rights reserved.
//

import UIKit

class MainTabBarController: UITabBarController {

    @IBOutlet weak var mainTabBar: MainTabBar!
    override func viewDidLoad() {
        super.viewDidLoad()

        addChildViewControllers()
        mainTabBar.composeButton.addTarget(self, action: "composeButtonDidClick", forControlEvents: UIControlEvents.TouchUpInside)
        
        
    }
    
    func composeButtonDidClick(){
        
    }
//添加子视图控制器
    
   private func addChildViewControllers(){
        //self.tabBar.tintColor = UIColor.orangeColor()
        addchildViewController("Home", "首页", "tabbar_home")
        addchildViewController("Message", "消息", "tabbar_message_center")
        addchildViewController("Discover", "发现", "tabbar_discover")
        addchildViewController("Profile", "我", "tabbar_profile")

        
    }
    
    //添加单视图控制器
//    private 只在本类中调用
   private func addchildViewController(sbName: String, _ title: String, _ imageName: String) {
       
        let sb = UIStoryboard(name: sbName, bundle: nil)
        
        let nav = sb.instantiateInitialViewController() as! UINavigationController
        nav.topViewController?.title = title
        nav.tabBarItem.image = UIImage(named: imageName)
        
        addChildViewController(nav)
        
    }
    
    
    
    
    
    
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    
    
}
